package conf

import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

// QiniuSection map toml [qiniu]
type QiniuSection struct {
	BucketURI string `mapstructure:"bucket_uri"`
	AccessKey string `mapstructure:"access_key"`
	SecretKey string `mapstructure:"secret_key"`
}

// ReadQiniu get qiniu section from config
func ReadQiniu(v *viper.Viper, slog *zap.SugaredLogger) (qiniuSection QiniuSection) {
	err := v.Unmarshal(&qiniuSection)
	if err != nil {
		slog.Panicf("unable to decode into qiniu section, %v", err)
	}
	slog.Debug(qiniuSection)
	return
}
